<template>
  <div class="pz_box" :class="styleOptions[hotCourseConfig.content.style]">
    <div v-for="(item, index) in hotCourseConfig.venueContent.customList" :key="index" class="pz_box_item mb3">
      <img class="pzImg" :src="item.icon || item.courseImage">
      <template v-if="item.bean && item.bean.flag">
        <div
          v-if="hotCourseConfig.content.param.indexOf('1') > -1"
          :class="item.bean.flag=='1'?'pz_box_item_box_tag blue':item.bean.courseType=='1'?'pz_box_item_box_tag': 'pz_box_item_box_tag lv'"
        >
          {{ item.bean.flag=='1'?'视频课':item.bean.courseType=='1'?'团体课':item.bean.courseType=='3'?'长期课': '私教课' }}
        </div>
        <div v-if="item.title || item.icon" class="pz_box_item_box">
          <div class="courseName">{{ item.title }}</div>
          <div v-if="hotCourseConfig.content.param.indexOf('2') > -1" class="bmNum">{{ item.bean.numJoin || 0 }}人已报名</div>
          <div class="pzFoot flex df_sb">
            <div v-if="hotCourseConfig.content.param.indexOf('3') > -1" class="price" :class="item.bean.price?'secondColor':'freePrice'">
              {{ item.bean.price?'¥':'免费' }}<span v-if="item.bean.price">{{ item.bean.price }}</span>
            </div>
            <!-- <div v-if="hotCourseConfig.content.param.indexOf('3') == -1" class="price" /> -->
            <div class="jl df_ac">
              <img v-if="hotCourseConfig.content.param.indexOf('5') > -1 && item.bean.teacherIcon" :src="item.bean.teacherIcon">
              <span v-if="hotCourseConfig.content.param.indexOf('4') > -1 && item.bean.teacherName" class="limit-1-line">{{ item.bean.teacherName }}</span>
            </div>
          </div>
        </div>
      </template>
      <template v-else>
        <div
          v-if="hotCourseConfig.content.param.indexOf('1') > -1"
          :class="item.flag=='1'?'pz_box_item_box_tag blue':item.courseType=='1'?'pz_box_item_box_tag': 'pz_box_item_box_tag lv'"
        >
          {{ item.flag=='1'?'视频课':item.courseType=='1'?'团体课':item.courseType=='3'?'长期课': '私教课' }}
        </div>
        <div class="pz_box_item_box">
          <div class="courseName">{{ item.courseName }}</div>
          <div v-if="hotCourseConfig.content.param.indexOf('2') > -1" class="bmNum">{{ item.joinNum || 0 }}人已报名</div>
          <div class="pzFoot flex df_sb">
            <div v-if="hotCourseConfig.content.param.indexOf('3') > -1" class="price" :class="item.price?'secondColor':'freePrice'">
              {{ item.price?'¥':'免费' }}<span v-if="item.price">{{ item.price }}</span>
            </div>
            <div v-if="hotCourseConfig.content.param.indexOf('3') == -1" class="price" />
            <div class="jl df_ac">
              <img v-if="hotCourseConfig.content.param.indexOf('5') > -1 && item.teacherImage" :src="item.teacherImage">
              <span v-if="hotCourseConfig.content.param.indexOf('4') > -1 && item.teacherName" class="limit-1-line">{{ item.teacherName }}</span>
            </div>
          </div>
        </div>
      </template>
    </div>
  </div>
</template>

<script>
// 大图，hd 滑动
export default {
  props: {
    config: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    return {
      hotCourseConfig: {
        content: {},
        venueContent: {
          customList: []
        }
      },
      styleOptions: {
        '1': 'hd',
        '2': 'dt',
        '3': 'zt',
        '4': 'sx'
      }
    }
  },
  watch: {
    config(val) {
      this.hotCourseConfig = this.config
    }
  }

}
</script>
<style lang="scss" scoped>
@import '@/styles/variables.scss';
	.pz_box {
		.pzImg {
			vertical-align: top;
		}
		.pz_box_item {
			width: 100%;
			background: #FFFFFF;
			border-radius: 8px;
			position: relative;
			overflow: hidden;

			.pz_box_item_box_tag {
				position: absolute;
				top: 20px;
				left: 20px;
				padding: 5px;
				display: flex;
				align-items: center;
				justify-content: center;
				background: $Color;
				border-radius: 8px;
				font-size: 22px;
				color: #FFFFFF;

				&.blue {
					background: $blueBg;
				}

				&.lv {
					background: linear-gradient(270deg, #6BE599 0%, #14B76D 100%);
				}
			}

			.courseName {
				font-size: 30px;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #222222;
				line-height: 1;
				margin-bottom: 20px;
			}

		}

		.pzFoot {
			.price {
				font-size: 24px;

				text {
					font-size: 32px;
					font-weight: bolder;
				}
			}

			.jl {
				font-size: 24px;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #666666;
				max-width: 50%;

				img {
					width: 44px;
					height: 44px;
					border-radius: 50%;
					margin-right: 10px;
				}
			}
		}
		&.dt,
		&.sx {
			.pz_box_item {
				// border: 1px solid #E5E5E5;

				.pzImg {
					width: 100%;
					height: 388px;
				}

				.pz_box_item_box {
					position: static;
					box-sizing: border-box;
					padding: 20px;

					.bmNum {
						position: absolute;
						top: 325px;
						left: 20px;
						line-height: 42px;
						background: rgba(0, 0, 0, 0.6);
						border-radius: 22px;
						color: #fff;
						padding: 0 10px;
					}

				}
			}
		}

		&.sx {
			display: flex;
			flex-wrap: wrap;
			background-color: #fff;
			&:before {
				clear: both;
				content: '';
				display: block;
			}

			.pz_box_item {
				// border: 1px solid #E5E5E5;
				width: 49%;
				float: left;
				box-sizing: border-box;
				margin-right: 2%;

				&:nth-child(2n) {
					margin-right: 0;
				}
				.pzImg {
					height: 188px;
				}

				.pz_box_item_box {
					.bmNum {
						top: 136px;
					}

					.courseName {
            height: 80px;
						overflow: hidden;
						text-overflow: ellipsis;
						display: -webkit-box;
						line-height: 40px;
						-webkit-line-clamp: 2;
						/* autoprefixer: off */
						-webkit-box-orient: vertical;
						/* autoprefixer: on */
					}
				}

			}
		}

		&.hd {
      display: flex;
      width: 100%;
      overflow-x: auto;

			.pz_box_item {
        flex-shrink: 0;
				// border: 1px solid #E5E5E5;
				width: 440px;
				display: inline-block;
				margin-right: 30px;

				&:last-of-type {
					margin-right: 0;
				}

				.pzImg {
					width: 100%;
					height: 247px;
				}

				.pz_box_item_box {
					position: static;
					box-sizing: border-box;
					padding: 20px;
					background-color: #fff;

					.courseName {
						overflow: hidden;
						margin-bottom: 15px;
						text-overflow: ellipsis;
						display: -webkit-box;
						line-height: 40px;
						-webkit-line-clamp: 1;
						/* autoprefixer: off */
						-webkit-box-orient: vertical;
						/* autoprefixer: on */
					}

					.bmNum {
						font-size: 24px;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #999999;
						margin-bottom: 10px;
					}
				}
			}
		}

		&.zt {
			.pz_box_item {
				display: flex;
				justify-content: space-between;
				background: none;

				.pzImg {
					width: 260px;
					border-radius: 8px;
					flex: none;
					height: 146px;
				}

				.pz_box_item_box {
					flex: 1;
					box-sizing: border-box;
					padding-left: 20px;
					position: static;

					.courseName {
						overflow: hidden;
						text-overflow: ellipsis;
						display: -webkit-box;
						line-height: 1.3;
						-webkit-line-clamp: 2;
						/* autoprefixer: off */
						-webkit-box-orient: vertical;
						/* autoprefixer: on */
					}

					.bmNum {
						font-size: 24px;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #999999;
						margin-bottom: 10px;
					}
				}
			}
		}
	}
</style>
